﻿using System;
using System.Reflection;

namespace CodeLibrary.Reflection.Delegate
{
    public static class PropertyInfoExtensions
    {
        public static object FastGetValue(this PropertyInfo propertyInfo, object obj)
        {
            if (propertyInfo == null)
                throw new ArgumentNullException("propertyInfo");

            return GetterSetterFactory.GetPropertyGetterWrapper(propertyInfo).Get(obj);
        }

        public static void FastSetValue(this PropertyInfo propertyInfo, object obj, object value)
        {
            if (propertyInfo == null)
                throw new ArgumentNullException("propertyInfo");

            GetterSetterFactory.GetPropertySetterWrapper(propertyInfo).Set(obj, value);
        }

    }
}
